﻿using UnityEngine;
using System.Collections;

public class TaskItemsNeedAdded : MonoBehaviour {
	public static TaskItemsNeedAdded _instance;
	/// 待添加TaskItem的列表
	public TaskItem[] TaskItemList{get{ return taskItemList;}}
	TaskItem[] taskItemList;
	void Awake(){
		_instance = this;
		taskItemList = GetComponentsInChildren<TaskItem> ();
	}
	/// <summary>
	/// 根据名字从任务物品列表中获取TaskItem脚本
	/// </summary>
	/// <returns>The task item in all.</returns>
	/// <param name="itemName">Item name.</param>
	public static TaskItem GetTaskItem(string itemName){
		foreach (TaskItem ti in _instance.taskItemList) {
			if (ti.Name == itemName) {
				return ti;
			}
		}
		Debug.Log ("There is no item named " + itemName + " in allTaskItems!");
		return null;
	}
}
